var supports = []

function addsupport(artid) {
    var index = supports.indexOf(artid);
    var currsuupot = Number($("#support" + artid).text())
    if (index > -1) {
        --currsuupot;
        supports.splice(index, 1)
    } else {
        ++currsuupot;
        supports.splice(index, 0, artid)
    }

    $.ajax({
        type: 'post',
        url: '/article/update_support',
        contentType: "application/json",
        data: JSON.stringify({
            artid: artid,
            currsuupot: currsuupot
        }),
        success: function (rescode) {
            if (rescode != "200") {
                loginmodal();
            }else{
                $("#support" + artid).text(currsuupot);
            }
        },
        error: function () {
            loginmodal();
        }
    });
}
